<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>消息管理</title>
 <%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
  <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
   <link rel="stylesheet" href="/css/global.css" media="all" />
    <link rel="stylesheet" href="/css/tab.css" media="all" />
 
</head>
<body>


<div class="admin-tab admin-user admin-role">
    <div class="tab-condition">
        <div class="TM-tab-info">
            <a class="layui-btn layui-btn-primary layui-btn-small active  sendmessageall">+发送消息</a>
      
        </div>
    </div>
    <div class="layui-field-box">
        <table class="site-table table-hover TM-user">
            <thead>
            <tr class="tableHeader">
                <th style="width:5%;text-align:center; padding-left:0; ">头像</th>
					<th style="width:15%">账号</th>
					<th style="width:10%;">终端</th>
					<th style="width:10%;">终端版本</th>
					<th style="width:10%;">应用版本</th>
					<th style="width:10%;">设备型号</th>
					<th style="width:10%;">在线时长</th>
					<th style="width:20%;">位置</th>
					<th style="width:10%;">操作</th>
				</tr> 
            </thead>
            <tbody>
            
                   <c:forEach  var="user" items="${userlist}">
                                 	<tr id="${user.account}">
                                        <td>
											
										</td>
										<td>
											${user.account}[${user.name}]
										</td>
										<td>
											${user.channel} 
										</td>
										<td>
											${user.systemVersion} 
										</td>
										<td>
											${user.clientVersion} 
										</td>
										<td>
											${user.deviceModel} 
										</td>
										<td>
										 <%--   <%=(System.currentTimeMillis()- request.getAttribute("bindTime"))/1000 %>秒 --%>
										</td>
										<td>
										  ${user.location}  
										</td>
										<td>
										   <button class="layui-btn layui-btn-primary layui-btn-small sendmessage"  data="${user.account}"><i class="layui-icon "></i></button>
										</td>
									</tr>	
						</c:forEach>
              
            </tbody>
        </table>
        <%-- <div class="admin-table-page">
        	 ${pager.getShowPage() }
            <div id="page" class="page"><div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-0"><span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>1</em></span><a href="javascript:;" data-page="2">2</a><a href="javascript:;" data-page="3">3</a><a href="javascript:;" data-page="4">4</a><a href="javascript:;" data-page="5">5</a><span>…</span><a href="javascript:;" class="layui-laypage-last" title="尾页" data-page="25">末页</a><a href="javascript:;" class="layui-laypage-next" data-page="2">下一页</a></div></div>
        </div> --%>
    </div>
</div>


<div class="layui-form-item" id="validatemessage-formDiv" style="width:90%;margin-top:20px;display:none">
<form  class="layui-form clefix" action="" id="validatemessage-form" method="post">
	<div class="layui-form-item">
	    
	  <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">内容</label>
	    <div class="layui-input-block">	 
	      <textarea   placeholder="请输入内容"  id="content" name="content"  class="layui-textarea"></textarea>
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">发送</button>
	    </div>
	  </div>  
	</div>
</form>
</div>

<script>
   var id ="";
    layui.use(['icheck','element','laypage','form'], function() {
        var $ = layui.jquery ;
        var form = layui.form();
 
    	 
 
    	$(".sendmessage").on('click', function() {
    		 id = $(this).attr("data"); 
    		layer.open({
				title: '发送消息',
				maxmin: true,
				type: 1,
				content:  $('#validatemessage-formDiv'),
				area: ['900px', '450px']
			});
    	});  
    	
    	$(".sendmessageall").on('click', function() {
    		id = "";
    		 
    		layer.open({
				title: '全体发送',
				maxmin: true,
				type: 1,
				content:  $('#validatemessage-formDiv'),
				area: ['900px', '450px']
			});
    	});  
    	
    	
     $("#validatemessage-form").validate({
		 rules: {
			       content: "required",
		      },
		      messages: {
		    	  content: "请输入消息内容",
		      },
		 submitHandler: function(form) {
			 
			 var content =$("#content").val();
			 $.ajax({
					type : "POST",
					url : "/user/sendsysmessage",
					data : {
						type:"2",
						content : content, 
						receiver:id
					},
					dataType : "json",
					success : function(data) {
						if (data.code != 200) {
						     layer.msg("失败!");
						} else {
					    	 layer.msg('成功', {icon: 1}); 
						}
					}
				});
			 
	      }
	 
	    });
    	
    }); 
 
</script>

 
	
</body>

</html>